// 写一个程序创建进程扇（即一个父进程创建3个并列的子进程）
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>

int main(int argc,char*argv[])
{
    pid_t cpid;
    pid_t spid;
    pid_t tpid;
    cpid=fork();
    if(cpid < 0)
    {
        printf("error");
        return 1;
    }
    else if(cpid > 0)
    {
        spid=fork();
        if(spid < 0)
        {
            printf("error");
            return 1;
        }
        else if(spid > 0)
        {
            tpid=fork();
            if(tpid < 0)
            {
                printf("error");
                return 1;
            }
            else if(tpid > 0)
            {
                printf("In parent process,pid = %d\n",getpid());
            }
            else
            {
                printf("In child 3 process,pid = %d\n",getpid());
            }
        }
        else
        {
            printf("In child 2 process,pid = %d\n",getpid());
        }
    }
    else
    { 
        printf("In child 1 process,pid = %d\n",getpid());
    }
    

    return 0;
}